﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestPInvoke
{


    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    public struct HWND__
    {

        /// int
        public int unused;
    }

    public class NativeMethods
    {

        /// Return Type: int
        ///hWnd: HWND->HWND__*
        ///lpText: LPCWSTR->WCHAR*
        ///lpCaption: LPCWSTR->WCHAR*
        ///uType: UINT->unsigned int
        [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "MessageBoxW")]
        public static extern int MessageBoxW([System.Runtime.InteropServices.InAttribute()] System.IntPtr hWnd, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpText, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpCaption, uint uType);

        public const int MB_OK = 0; //type的常量 MB_OK=0 显示一个只有“确定”按钮的消息框 
    }


    class Program
    {
        static void Main(string[] args)
        {
            NativeMethods.MessageBoxW(IntPtr.Zero, "Hello world.", "P/Invoke", NativeMethods.MB_OK);
        }
    }
}
